/**
 * Created by Administrator on 2017/1/16.
 */

module.exports = function(app) {
    return new Handler(app);
};

var Handler = function(app) {
    this.app = app;
};

var handler = Handler.prototype;

function RegisterHandler(name) {
    handler[name] = function(msg, session, next) {
        var room = session.room;

        var handleName = "handle" + name.capWord();
        room.callHandler(handleName, session.player, msg, function(resp) {
            next(null, resp);
        });
    }
}

RegisterHandler("playerReady");
RegisterHandler("destroyRoom");
RegisterHandler("reqDestroyRoom");
RegisterHandler("respDestroyRoom");
RegisterHandler("quitRoom");
RegisterHandler("forceQuitRoom");
RegisterHandler("chat");
RegisterHandler("setBackground");
//房主开启游戏
RegisterHandler('creatorStart');